--Classe pour effectuer les actions lorsque l'algo est en production
Action = {}

function Action:passe(simulation)
   io.write("passe\n")
   io.flush()
   return (Simulate:passe(simulation))
end

function Action:acheter(simulation, n)
   if (n > 0) and (Calcul:isPossibleBuy(n, Anal.current, Anal.money)) then
      Anal.nb_action = n + Anal.nb_action
      Anal.money = Anal.money - ((n * Anal.current) + (Calcul:getPourcentage(n, Anal.current)))
      io.write("buy " .. n .. "\n")
      io.flush()
      return (Simulate:acheter(simulation, n))
   else
      return (Action:passe(simulation))
   end
end

function Action:vendre(simulation, n)
   if (n > 0) and (n <= Anal.nb_action) then
      Anal.nb_action = Anal.nb_action - n
      Anal.money = Anal.money + (n * Anal.current) - (Calcul:getPourcentage(n, Anal.current))
      io.write("sell " .. n .. "\n")
      io.flush()
      return (Simulate:vendre(simulation, n))
   else
      return (Action:passe(simulation))
   end
end